package com.example.mytest

import org.junit.Assert.assertEquals
import org.junit.Test

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {
    @Test
    fun addition_isCorrect() {
        assertEquals(4, 2 + 2)
    }


    @Test
    fun rxcreat() {
        /*//被观察者
        val observable = Observable.create<String> {
            it.onNext("1")
            it.onNext("2")
            it.onNext("3")
            it.onNext("4")
            it.onNext("5")
            it.onNext("6")
            it.onComplete()
        }


        //观察者
        val stringObserver = object :Observer<String>{
            override fun onComplete() {
                print("onComplete")
            }

            override fun onSubscribe(d: Disposable) {

                print("onSubscribe")
            }

            override fun onNext(t: String) {
                println(t)
            }

            override fun onError(e: Throwable) {
                println(e.message.toString())
            }
        }

        //建立联系, 订阅
        observable.subscribe(stringObserver)*/
        /*      //链式写法
              Observable.create<Int> {
                  it.onNext(1)
                  it.onNext(2)
                  it.onNext(3)
                  it.onNext(4)
                  it.onNext(5)
                  it.onComplete()
              }.subscribe(object : Observer<Int> {
                  override fun onComplete() {
                      println("完成")
                  }

                  override fun onSubscribe(d: Disposable) {
                      println("onSubscribe")
                  }

                  override fun onNext(t: Int) {
                      println(t)
                  }

                  override fun onError(e: Throwable) {
                  }
              })*/

        /*  //将一个或者多个数据发送 多个实现From操作符
          Observable.just(1,"asda").subscribe {
              println(it)
          }*/

/*
        var list = mutableListOf<String>()
        Observable.fromArray(list).subscribe {
        }*/


        /*   Observable.timer(1000,TimeUnit.MILLISECONDS).subscribe {
               println("sasda")
           }*/

        /*Observable.interval(1,TimeUnit.SECONDS).subscribe {
            print(it)
        }*/
    }


    @Test
    fun rxmerge() {


        val toString = 16.toString(16)
        val toInt = "0c".toInt(16)
        print(toInt)


    }
}
